<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$this->load->view('header', array('title' => '我的相册'));
?>
<div class="main">
	<div class="left">
		<div class="menu">
			<p class="current"><a href="?c=album&m=index">我的相册</a></p>
			<p><a href="?c=album&m=add">创建相册</a></p>
            <?php
            if ($this->member->is_admin())
            {
                echo '<p><a href="?c=album&m=manage">管理相册</a></p>';
            }
            ?>
		</div>
		<ul class="tab_list">
            <li style="width:210px;background-color:#ccc;height:22px;line-height:22px;font-size:12px;">相册名称</li>
            <li style="width:330px;background-color:#ccc;height:22px;line-height:22px;font-size:12px;">相册链接</li>
            <li style="width:180px;background-color:#ccc;height:22px;line-height:22px;font-size:12px;">操作</li>
        <?php
        if (empty($rowset))
        {
            echo '您还没有相册，请先<a href="?c=album&m=add">创建相册</a>。';
        }

        foreach ($rowset as $rows)
        {
            $album_url = $this->config->item('base_url') . '/' . $this->album->get_dir($rows['album_id']) . '/index.html';
        ?>
			<li style="width:210px;text-align:left;"><a href="<?php echo $album_url;?>" target="_blank"><?php echo $rows['album_name'];?></a></li>
			<li style="width:330px;"><input type="text" value="<?php echo $album_url;?>" onclick="this.select();" style="width:330px;font-size:12px;"></li>
			<li style="width:180px;">
            <a href="?c=album&m=picture&id=<?php echo $rows['album_id'];?>">图片</a>&nbsp;&nbsp;<span style="color:#ccc">|</span>&nbsp;&nbsp;
            <a href="?c=album&m=update&id=<?php echo $rows['album_id'];?>">修改</a>&nbsp;&nbsp;<span style="color:#ccc">|</span>&nbsp;&nbsp;
            <a href="javascript:void(0);" onclick="remove(<?php echo $rows['album_id'];?>);return false;">删除</a>
            </li>
        <?php
        }
        ?>
		</ul>
		<p style="height:10px">&nbsp;</p>
	</div>
    <?php
    $this->load->view('right');
    ?>
</div>
<script type="text/javascript">
function remove(id)
{
    $.post('?c=album&m=remove', {"id":id}, function(response) {
        
        if (response.error_code)
        {
            alert(response.msg);
        }
        else
        {
            window.location.reload();
        }
    }, "json");
}
</script>
<?php
$this->load->view('footer');
?>